# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Joris Steyn <jorissteyn@gmail.com>
# Contributor: fnord0 <fnord0 AT riseup DOT net>

pkgname=zaproxy
pkgver=2.11.1
pkgrel=2
pkgdesc='Integrated penetration testing tool for finding vulnerabilities in web applications'
url='https://www.owasp.org/index.php/ZAP'
arch=('any')
license=('Apache')
depends=('bash' 'java-runtime' 'ttf-font')
_java=8
makedepends=('gradle' "java-environment=${_java}")
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/zaproxy/zaproxy/archive/v${pkgver}.tar.gz")
sha512sums=('7018e6a71a4e75c5061f01a36dbdc89b3b8109aa86e81783351e2a2abdbbde2646c6c7cbdc3dd97f628e58506d0feb4467d5f040843c6d09fbd2a341cb9052fa')
b2sums=('402417e705715c0648d03928078965a1d8958019fe3961c6015bff24da1c6a60f384cb16595c0e339f0c175a1f7a54ec9abd3676b5754d7834314e4183337e59')

prepare() {
  cd ${pkgname}-${pkgver}
  cat > ${pkgname} <<EOF
#!/bin/sh
cd /usr/share/zaproxy
./zap.sh
cd -
EOF

  # https://security.archlinux.org/AVG-2626
  sed -i 's/log4jVersion = "2.15.0"/log4jVersion = "2.17.1"/' zap/zap.gradle.kts
}

build() {
  cd ${pkgname}-${pkgver}
  export PATH="/usr/lib/jvm/java-${_java}-openjdk/bin:$PATH"
  export JAVA_HOME="/usr/lib/jvm/java-${_java}-openjdk"
  gradle :zap:distLinux
}

package() {
  cd ${pkgname}-${pkgver}
  install -d "${pkgdir}/usr/share/${pkgname}"
  tar zxf zap/build/distributions/ZAP_${pkgver}_Linux.tar.gz
  cp -pR ZAP_${pkgver}/. "${pkgdir}/usr/share/${pkgname}"
  install -Dm 755 ${pkgname} "${pkgdir}/usr/bin/${pkgname}"
}

# vim: ts=2 sw=2 et:
